// 倒计时
import "./FormatMoment.css"
import React,{useState,useEffect} from 'react';

const FormatMoment=(props)=>{
    const [durTime,setDurTime]=useState(43200000)
    useEffect(()=>{
        if(durTime>0){
            setTimeout(()=>{
                setDurTime(durTime-1000)
            },1000)
            // console.log(durTime);
        }
        else{
          return setDurTime(()=>{
              durTime+43200000
          })
        }
    },[durTime])
    let hours=Math.floor(durTime/60/60/1000)
    let minute=Math.floor(durTime/1000)
    let second=Math.floor(durTime%(1000*60)/1000)
    return(
        <>
        <div className="time">
                <span>{hours}</span>:
                <span>{minute}</span>:
                <span>{second}</span>
            </div>
        </>
    )
} 
export default FormatMoment 